import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";

function _templateObject() {
  var data = _taggedTemplateLiteral(["\n  margin-top: 8px;\n"]);

  _templateObject = function _templateObject() {
    return data;
  };

  return data;
}

import React from "react";
import styled from "styled-components";
import intl from "cpaas-front/lib/utils/intl";
import { BlockContainer } from "./index.style";
import SectionTitle from "../_components/SectionTitle";
import ConfigItem from "../_components/ConfigItem";
import withFormOperate from "../_components/withFormOperate";
import { getMemoizedAssets, getStaticGif } from "./util";
import MotionTitle from "../_components/MotionTitle";
var StyledConfigItem = styled(ConfigItem)(_templateObject());

var ButtonConfig = /*#__PURE__*/function (_React$Component) {
  _inherits(ButtonConfig, _React$Component);

  function ButtonConfig() {
    var _getPrototypeOf2;

    var _this;

    _classCallCheck(this, ButtonConfig);

    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(ButtonConfig)).call.apply(_getPrototypeOf2, [this].concat(args)));
    _this.getButtons = getMemoizedAssets(_this.props.styleCounts.button, "button");
    _this.getMotions = getStaticGif( // this.props.styleCounts.buttonMotion,
    _this.props.styleCounts.buttonMotion, // 2,
    "button/motions", "png", 1);
    _this.getMotions2 = getStaticGif(_this.props.styleCounts.buttonMotion, // 2,
    "button/motions", "png", 2);
    return _this;
  }

  _createClass(ButtonConfig, [{
    key: "render",
    value: function render() {
      var _this$props = this.props,
          handleChange = _this$props.handleChange,
          value = _this$props.value,
          schema = _this$props.schema;
      return React.createElement(BlockContainer, {
        className: "block-container",
        id: "button-config"
      }, React.createElement(SectionTitle, {
        title: "\u6309\u94AE",
        titleTail: "Button",
        style: {
          marginTop: 0
        }
      }), React.createElement(StyledConfigItem, {
        title: intl.get("cpaas.cpaasTheme.page.buttonWithIcon").d("主按钮带图标+次按钮"),
        items: this.getButtons(schema),
        defaultSelected: value.button,
        onChange: handleChange("button")
      }), React.createElement(StyledConfigItem, {
        simple: true,
        title: React.createElement(MotionTitle, {
          text: intl.get("cpaas.cpaasTheme.page.animation").d("动效") + 1
        }),
        defaultSelected: value.buttonMotion,
        items: this.getMotions(schema),
        onChange: handleChange("buttonMotion")
      }), React.createElement(StyledConfigItem, {
        simple: true,
        title: React.createElement(MotionTitle, {
          text: intl.get("cpaas.cpaasTheme.page.animation").d("动效") + 2
        }),
        defaultSelected: value.buttonMotion2,
        items: this.getMotions2(schema),
        onChange: handleChange("buttonMotion2")
      }));
    }
  }]);

  return ButtonConfig;
}(React.Component);

ButtonConfig.defaultProps = {
  originTheme: {
    button: []
  }
};
export default withFormOperate(ButtonConfig);
